package br.mikhas.lang.struct;

import java.util.List;

public class Class extends AbstractAccessibleStructure {
	/**
	 * The class name
	 */
	protected String name;

	/**
	 * Parent class
	 */
	protected Class parent;

	/**
	 * Class fields
	 */
	protected List<Field> fields;

	/**
	 * Class methods
	 */
	private List<Method> methods;

	/**
	 * Adds field to class
	 * 
	 * @param field
	 */
	public void addField(Field field) {
		field.declaringClass = this;

		if (!fields.contains(field))
			fields.add(field);
	}

	public void addMethod(Method method) {
		method.declaringClass = this;

		if (!methods.contains(method))
			methods.add(method);
	}

	@Override
	public String toString() {
		return this.name;
	}

	@Override
	public int hashCode() {
		return name.hashCode();
	}

}
